<?php
/**
 * 接口
 */
namespace app\manage\controller\operate;

use app\manage\controller\Base;

class Api extends Base
{
	/**
	 * 资产变动记录类型
	 */
	public function coin_record_type(){
		$params = $this->request->param();
		$type = isset($params['type'])?$params['type']:null;
		$data = model('member_coin_record')::operate($type);
		return json($data);
	}
	/**
	 * 资产变动增减接口
	 * @return [type] [description]
	 */
	public function coin_record_flag(){
		$params = $this->request->param();
		$flag = isset($params['flag'])?$params['flag']:null;
		$data = model('member_coin_record')::flag($flag);
		return json($data);
	}
	/**
	 * 状态接口
	 * @return [type] [description]
	 */
	public function status_charge(){
		$params = $this->request->param();
		$status = isset($params['status'])?$params['status']:null;
		$data = model('operate_charge')::status($status);
		return json($data);
	}
	public function status_withdraw(){
		$params = $this->request->param();
		$status = isset($params['status'])?$params['status']:null;
		$data = model('operate_withdraw')::status($status);
		return json($data);
	}
	public function status_transfer(){
		$params = $this->request->param();
		$status = isset($params['status'])?$params['status']:null;
		$data = model('operate_transfer')::status($status);
		return json($data);
	}
	public function status_convert(){
		$params = $this->request->param();
		$status = isset($params['status'])?$params['status']:null;
		$data = model('operate_convert')::status($status);
		return json($data);
	}

	/**
	 * 资产变动记录
	 * @return [type] [description]
	 */
	public function coin_record(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('member_coin_record')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);

	}

	/**
	 * 转账记录
	 * @return [type] [description]
	 */
	public function record_transfer(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('operate_transfer')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);

	}

	/**
	 * 货币转换记录
	 * @return [type] [description]
	 */
	public function record_convert(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('operate_convert')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);
	}

	/**
	 * 充值记录
	 * @return [type] [description]
	 */
	public function record_charge(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('operate_charge')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);

	}

	/**
	 * 提现记录
	 * @return [type] [description]
	 */
	public function record_withdraw(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('operate_withdraw')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);

	}





	// /**
	//  * 资金变动记录
	//  * @return [type] [description]
	//  */
	// public function coin_record(){
	// 	$params = $this->request->param();

	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);
		
	// 	$query = new \app\common\query\MemberCoinRecord;
	// 	$data = $query -> getRows($where,$queryStr,url('operate.show/index'));
	// 	return json($data);
	// }

	// public function record_transfer(){
	// 	$params = $this->request->param();

	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);

	// 	$query = new \app\common\query\OperateTransfer;
	// 	$data = $query -> getRows($where,$queryStr,url('operate.show/transfer'));
	// 	return json($data);
	// }

	// public function record_convert(){
	// 	$params = $this->request->param();

	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);

	// 	$query = new \app\common\query\OperateConvert;
	// 	$data = $query -> getRows($where,$queryStr,url('operate.show/convert'));
	// 	return json($data);
	// }

	// public function record_charge(){
	// 	$params = $this->request->param();

	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);

	// 	$query = new \app\common\query\OperateCharge;
	// 	$data = $query -> getRows($where,$queryStr,url('operate.show/charge'));
	// 	return json($data);
	// }

	// public function record_withdraw(){
	// 	$params = $this->request->param();

	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);

	// 	$query = new \app\common\query\OperateWithdraw;
	// 	$data = $query -> getRows($where,$queryStr,url('operate.show/withdraw'));
	// 	return json($data);
	// }

}